
    public class Timer extends Thread{
        int time=0;
        public Timer(int time){
            this.time = time;
        }
        public void run(){
            try {
                for (int i = 0; i <= time; i++) {
                    Thread.sleep(1000);
                    System.out.println(i+"秒");
                }
            } catch (Exception e) {
                System.out.println(e.toString());
            }
        }
        public static void main(String[] args) {
            Timer timer = new Timer(5);
            timer.run();
        }
    }

